<template>
  <el-container class="home-container">
    <!-- 头部区域 -->
    <el-header>
      <div>
        <img src="../assets/heima.png" alt="logo" />
        <span>在役检查管理系统</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>

    <!-- 页面主体区域 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <!-- 折叠按钮 -->
        <div class="toggle-button" @click="toggleCollapse">|||</div>

        <el-menu
          background-color="#333744"
          text-color="#fff"
          active-text-color="#409EFF"
          unique-opened
          :collapse="isCollapse"
          :collapse-transition="false"
          router
        >
          <el-submenu index="100">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>证书管理</span>
            </template>
            <el-menu-item index="/member">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>成员管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/liscense">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>证书列表</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/liscensetab">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>统计数据</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="200">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>缺陷跟踪</span>
            </template>
            <el-menu-item index="/adddefect">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>新增缺陷</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/defect">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>缺陷管理</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="400">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>经验反馈</span>
            </template>
            <el-menu-item index="/feedback">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>经验反馈管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/feedback">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>统计数据</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="300">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>涡流数据</span>
            </template>
            <el-menu-item index="/etdataadd">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>数据导入</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/etdatasearch">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>数据查询</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="500">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>数据维护</span>
            </template>
            <el-menu-item index="/baseinfo">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>后台管理</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/outage">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>大修轮次管理</span>
              </template>
            </el-menu-item>
          </el-submenu>

          <el-submenu index="600">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>个人信息</span>
            </template>
            <el-menu-item index="/changepassword">
              <template slot="title">
                <i class="el-icon-location"></i>
                <span>修改密码</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 右侧内容主体 -->
      <el-main><router-view></router-view></el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      isCollapse: false
    }
  },
  created() {},
  methods: {
    logout() {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    // 点击按钮实现菜单的折叠与展开
    toggleCollapse() {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style lang="less" scoped>
.home-container {
  height: 100%;
}

.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 20px;
  > div {
    display: flex;
    align-items: center;
    span {
      margin-left: 15px;
    }
    img {
      height: 60px;
    }
  }
}
.el-aside {
  background-color: #333744;
  .el-menu {
    border-right: none;
  }
}
.el-main {
  background-color: #eaedf1;
}

.toggle-button {
  background-color: #4a5064;
  color: #eaedf1;
  line-height: 24px;
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  cursor: pointer;
}
</style>
